package problem;

import java.util.Random;

/**
 * cpu 100%
 */
public class Cpu100Demo {
    public static void main(String[] args) {
        new Thread(() -> {
            Thread.currentThread().setName("CPU100-Thread");
            int i = 0;
            for(;;)
                i ++;
        }).start();
        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                Random random = new Random();
                int n = 0;
                for (int j = 0; j < 10000; j++) {
                    n ++;
                    try {
                        Thread.sleep(random.nextInt(100));
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(Thread.currentThread() + ": " + n);
            }).start();
        }
    }
}
